package com.nbcio;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import lombok.extern.slf4j.Slf4j;

/**
 * 启动程序
 *
 * @author nbacheng
 */

@Slf4j
@SpringBootApplication
public class NbMadeApplication {

    public static void main(String[] args) throws UnknownHostException {
        SpringApplication application = new SpringApplication(NbMadeApplication.class);
        application.setApplicationStartup(new BufferingApplicationStartup(2048));
        ConfigurableApplicationContext applicationContext = application.run(args);
        Environment env = applicationContext.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path").trim();
        log.info("\n\t----------------------------------------------------------\n\t" +
                "Application nbmade-boot is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "\n\t" +
                "Swagger文档: \thttp://" + ip + ":" + port + path + "doc.html\n\t" +
                "♥◠‿◠)ﾉﾞ  nbmade-boot启动成功   ლ(´ڡ`ლ)，欢迎使用！ﾞ" + "\n\t" +
                "----------------------------------------------------------");
    }

}
